<ui:composition 
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:ui="http://java.sun.com/jsf/facelets">

    <h:form id="aloForm">  

        <p:growl id="msgs" showDetail="true"/>  

        <p:dataTable id="aloTaula" var="alo" value="#{alokairuZerrenda.zerrenda}" emptyMessage="Ez da alokairurik aurkitu" paginator="true" rows="10" editable="true" >  

            <!-- TAULAREN IZENA -->
            <f:facet name="header">  
                <span style="font-size: 18px; text-align: center">ALOKAIRUAK</span> 
            </f:facet> 

            <p:column filterBy="#{alo.instalazioa}" headerText="INSTALAZIO ID" >  
                <h:outputText value="#{alo.instalazioa}" /> 
            </p:column> 

            <p:column filterBy="#{alo.bezeroa}" headerText="BEZERO ID" > 
                <h:outputText value="#{alo.bezeroa}" /> 
            </p:column>  

            <p:column filterBy="#{alo.data}" headerText="DATA" >  
                <h:outputText value="#{alo.data}" /> 
            </p:column>  

            <p:column filterBy="#{alo.ordua}" headerText="ORDUA" >  
                <h:outputText value="#{alo.ordua}" /> 
            </p:column>  


            <p:column style="width: 90px">  

                <center>
                    <p:commandButton id="selectButton" update=":tabView:aloForm:aloDisplay" oncomplete="aloDialog.show()" icon="ui-icon-search" title="Ikusi">  
                        <f:setPropertyActionListener value="#{alo}" target="#{alokairuZerrenda.selectedAlokairua}" />  
                    </p:commandButton>  


                    <p:commandButton process="@this" id="ezabatuButton" update=":tabView:aloForm:aloTaula" actionListener="#{alokairuZerrenda.ezabatuAlokairua(alo)}"  oncomplete="javascript:location.reload(true)" icon="ui-icon-close" title="Ezabatu" > 
                    </p:commandButton> 
                </center>



            </p:column> 


        </p:dataTable> 




        <p:dialog header="Alokairuari buruzko informazioa" widgetVar="aloDialog" resizable="false" id="aloDlg" showEffect="fade" hideEffect="explode" modal="true">  

            <h:panelGrid id="aloDisplay" columns="2" cellpadding="4" style="margin:0 auto;">  

                <h:outputText value="INSTALAZIO ID:" />  
                <h:outputText value="#{alokairuZerrenda.selectedAlokairua.instalazioa}" style="font-weight:bold"/>  

                <h:outputText value="BEZERO ID" />  
                <h:outputText value="#{alokairuZerrenda.selectedAlokairua.bezeroa}" style="font-weight:bold"/>  

                <h:outputText value="DATA:" />  
                <h:outputText value="#{alokairuZerrenda.selectedAlokairua.data}" style="font-weight:bold"/>  

                <h:outputText value="ORDUA:" />  
                <h:outputText value="#{alokairuZerrenda.selectedAlokairua.ordua}" style="font-weight:bold"/>  

                <h:outputText value="OHARRA:" />  
                <h:outputText value="#{alokairuZerrenda.selectedAlokairua.oharra}" style="font-weight:bold"/> 
            </h:panelGrid>  

        </p:dialog> 

        <br/>
        <br/>
        <br/>

        <p:panel header="Alokairu berri bat sartu" style="font-size: 16px; text-align: center"> 
            <center>

                <h:panelGrid columns="2" id="grid" cellspacing="20px">  
                    <h:outputLabel value="Instalazioa: *" ></h:outputLabel>  
                    <p:selectOneMenu id="aloInstId" value="#{alokairuZerrenda.alo.instalazioa}" converter="instConv">                      
                        <f:selectItem itemLabel="Instalazioa"/>  
                        <f:selectItems value="#{instalazioZerrenda.zerrenda}" var="inst" itemLabel="#{inst.izena}"/>  
                    </p:selectOneMenu>


                    <h:outputLabel value="Bezeroa: *" ></h:outputLabel>  
                    <p:selectOneMenu id="aloBezId" value="#{alokairuZerrenda.alo.bezeroa}" converter="bezConv">                      
                        <f:selectItem itemLabel="Bezeroa"/>  
                        <f:selectItems value="#{bezeroZerrenda.zerrenda}" var="bez" itemLabel="#{bez.izena}"/>  
                    </p:selectOneMenu>


                    <h:outputLabel value="Data: *" ></h:outputLabel>  
                    <p:inputMask id="aloData" value="#{alokairuZerrenda.alo.data}"  mask="9999-99-99" /> 



                    <h:outputLabel value="Ordua: *" ></h:outputLabel>
                    <p:inputMask id="aloOrdua" value="#{alokairuZerrenda.alo.ordua}" mask="99:99 - 99:99" />


                    <h:outputLabel value="Oharra *" ></h:outputLabel>
                    <p:inputTextarea id="inputarea" rows="7" cols="20" value="#{alokairuZerrenda.alo.oharra}"/>  

                    <p:commandButton value="Ezabatu" type="reset"/> 


                    <p:commandButton id="gehitu" value="Alokairua gehitu" update="aloTaula msgs @parent" action="#{alokairuZerrenda.alokairuaGorde()}" > 
                        <p:collector value="#{alokairuZerrenda.alo}" addTo="#{alokairuZerrenda.zerrenda}" />  
                    </p:commandButton> 



                </h:panelGrid> 
            </center>

        </p:panel>

    </h:form>  

</ui:composition>



